﻿using System;
using System.Collections.Generic;
using HAVNet.Core.String;


namespace HAVNet.Intros.AST
{
    public class ASTCS3 : ASTNode
    {
        ASTExternAliasDirectives    _externalAliasDirectives= null;
        ASTUsings                   _usings                 = null;
        List<ASTGlobalAttributes>   _globalAttributesList   = null;
        ASTNamespaceMemberDecls     _namespaceMemberDecls   = null;

        public readonly string fileName = "";
        public ASTExternAliasDirectives externalAliasDirectives { get { if (null == _externalAliasDirectives) _externalAliasDirectives = new ASTExternAliasDirectives(); return _externalAliasDirectives; } }
        public ASTUsings                usings                  { get { if (null == _usings) _usings = new ASTUsings(); return _usings; } }
        public List<ASTGlobalAttributes>globalAttributesList    { get { if (null == _globalAttributesList) _globalAttributesList = new List<ASTGlobalAttributes>(); return _globalAttributesList; } }
        public ASTNamespaceMemberDecls  namespaceMemberDecls    { get { if (null == _namespaceMemberDecls) _namespaceMemberDecls = new ASTNamespaceMemberDecls(); return _namespaceMemberDecls; } }

        public ASTCS3 (string fileName)
        {
            this.fileName = fileName;
        }

        public override string ToString ()
        {
            var items = new List<string>();

            if (_externalAliasDirectives != null)
                if (externalAliasDirectives.Count > 0)
                    items.Add(externalAliasDirectives.ToString());

            if (_usings != null)
                if (usings.Count > 0)
                    items.Add(usings.ToString2(0));

            if (_globalAttributesList != null)
                if (globalAttributesList.Count > 0)
                    foreach (ASTGlobalAttributes ga in globalAttributesList)    
                        items.Add(ga.ToString());

            if (_namespaceMemberDecls != null)
                if (namespaceMemberDecls.Count > 0)
                    items.Add(namespaceMemberDecls.ToString());

            return Strings.joinobjs (Environment.NewLine, items);
        }
    }
}
